<?php
/*
 * 该函数用于输出表情图片
 * coded by: zuoxin
 * date: 2012-4-4
 * */
function show_expression($pre_weibo){
	$new_weibo = "";
	$expression = "";
	$n = strlen($pre_weibo);
	for	($i = 0; $i < $n; $i++){
		if ($pre_weibo[$i] != "["){
			$new_weibo .= $pre_weibo[$i];
		}
		else {
			$i++;
			while ( $i < $n ){
				if ($pre_weibo[$i] != "]"){
					$expression .= $pre_weibo[$i];
				}
				else {
					$my_sql_exp = mysql_query("select * from expression where e_name='$expression'");
					if (mysql_num_rows($my_sql_exp) == 1 ) {
						$my_result_exp = mysql_fetch_array($my_sql_exp);
						$new_weibo .= "<img src='".$my_result_exp[e_url]."'/>";
						$expression = "";
						break;
					}
					else {
						$new_weibo .= "[".$expression."]";
					}
				}
				$i++;
			}
		}
	}
	return $new_weibo;
}

?>